<template>
	<div>
		<uv-collapsePanel :class="item[showNum]==1?'ss-m-y-20':''" v-slot="{open}" @toggle="toggle($event,item,parent)"
			:key="index" v-for="item,index in list" :title="item[showTitle]" :num="item[showNum]" :status="item[showStatus]" :finishedTaskNum="item[showFinishedNum]"
			 :totalTaskNum="item[showTotalNum]" :inde="(index+1)" :lock="item[showLock]" :subPlanId="item.maintenanceSubPlanId" 
			 :floorId="item.buildingFloorId" :deviceId="item.deviceId" :deviceRemainTotal="item[showDeviceTotal]" :searchId="searchId">
			<!-- border-bottom: 1px solid #eaeaea;  :mes="item[showMes]"   :showMes="showMes"-->
			<div v-if="item[showName]" >
				<div class="names" :style="open?'':''" @click="Jump(i,item.deviceId)" v-for="(i,index) in item[showName]">
					<div class="ss-flex">
						<uv-icon v-if="i.passStatus!=2" name="checkmark-circle-fill" color="#4EA770" size="18"></uv-icon>
						<uv-icon v-if="i.passStatus==2" name="close-circle-fill" color="#FF3B30" size="18"></uv-icon>
						<div class="ss-m-x-10" >{{i.taskItemName}}</div>
					</div>
					<div class="ss-font-24 ss-m-x-50">已完成{{i.completedCount||0}} 应完成{{i.total||0}}</div>
				</div>
			</div>
			
			<uv-collapsePane-list :parent="[...parent,item]" :children="children" :num="showNum"
				:showName="showName" :showTitle="showDeviceName" :list="item[children]" :status="showStatus" :finishedTaskNum="showFinishedNum" :totalTaskNum="showTotalNum" 
				v-if="item[children] && item[children].length>0" :deviceRemainTotal="showDeviceTotal"></uv-collapsePane-list>
		</uv-collapsePanel>
	</div>
</template>

<script>
	export default {
		name: 'uv-collapsePane-list',
		props: {
			list: {
				type: Array,
				default () {
					return []
				},
			},
			parent: {
				type: Array,
				default () {
					return []
				},
			},
			searchId: {
				type: String,
				default: '',
			},
			showTitle: {
				type: String,
				default: 'systemName',
			},
			showDeviceName: {
				type: String,
				default: 'deviceName',
			},
			showName: {
				type: String,
				default: 'tasksItemList',
			},
			showFinishedNum: {
				type: String,
				default: 'completedCount',
			},
			showTotalNum: {
				type: String,
				default: 'total',
			},
			showDeviceTotal: {
				type: String,
				default: 'deviceRemainTotal',
			},
			children: { //需要识别的code标识
				type: String,
				default: 'deviceTasksList',
			},
			showNum: {
				type: String,
				default: 'level',
			},
			showStatus: {
				type: String,
				default: 'passStatus',
			},
			showLock: {
				type: String,
				default: 'lockStatus',
			},
		},
		data() {
			return {};
		},
		methods: {
			toggle(e, item, parent) {
				// console.log(e, item, parent, 'dddd')
				this.$emit('toggle', e, item, parent)
				// this.$emit('closeAllDescendants',e,item,parent)
			},
			Jump(i,deviceId){
				console.log(deviceId,'deviceId')
				let num = Number(i.total) - Number(i.completedCount)  
				uni.navigateTo({
					url:`/pages/Task/checkRecord?id=${deviceId}&completedCount=${i.completedCount}&num=${num}&taskItemId=${i.taskItemId}`
				})
			}
		}

	};
</script>

<style lang="scss" scoped>
	@import '@/uni.scss';

	.names {
		text-align: left;
		padding: 20rpx 20rpx;
		color: #666;
		font-size: 0.93rem;
		border: 1px solid #eaeaea;
	}
</style>